import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common';
import { RecordService } from './record.service';
import { CreateConfigInfoDto, CreateRecordDto } from './create-record.dto';

interface Response {
  message: string;
  code: number;
  data?: any[];
}

@Controller('record')
export class RecordController {
  constructor(private readonly recordService: RecordService) {}

  // 用于获取所有配置信息
  @Get('findAllInfo')
  async findAllInfo(): Promise<Response> {
    return this.recordService.findAllInfo();
  }

  // 用于删除配置信息
  @Delete('deleteInfo/:id')
  async deleteInfo(@Param('id') id: string): Promise<Response> {
    return this.recordService.deleteInfo(id);
  }

  // 用于保存所有配置信息
  @Post('saveAllInfo')
  async saveAllInfo(@Body() body: CreateConfigInfoDto): Promise<Response> {
    return this.recordService.saveAllInfo(body);
  }

  // 用于修改所有配置信息
  @Post('modifyAllInfo')
  async modifyAllInfo(@Body() body: CreateConfigInfoDto): Promise<Response> {
    return this.recordService.modifyAllInfo(body);
  }

  // 用于获取录制数据
  @Get('getRecording')
  async getRecording(): Promise<Response> {
    return this.recordService.getRecording();
  }

  // 接收前端发送的录制数据
  @Post('saveRecording')
  async saveRecording(@Body() body: CreateRecordDto): Promise<Response> {
    return this.recordService.saveRecording(body);
  }
}
